b = []
for o in range(100,1000):
    k = 0
    for i in range(2,o//2+1):
        if o % i == 0:
            k+=1 
    if k == 0:
        b.append(o)
print(b)
c = ["zero", "one", "two", "three", "four", "five", "six","seven", "eight", "nine"]
print(c.index("zero"))
vse = input()
if len(vse.split()) == 3:
    sot,des,edin = vse.split()
    if sot in c and des in c and edin in c:
        if sot == "zero":
            print("трехзначное не начинается с нуля!")
        else:
            chislo = c.index(sot)*100 + c.index(des)*10+c.index(edin)
            maxmenshe = 0 
            minbolshe = 10000
            for i in b:
                if i <= chislo:
                    maxmenshe = i
                if i >= chislo and minbolshe == 10000:
                    minbolshe = i
            print(minbolshe,chislo,maxmenshe)
            if chislo - maxmenshe > minbolshe-chislo:
 
                print(minbolshe)
            else:
                print(maxmenshe)
    else:
        print("Wrong!")
else:
    print("Wrong!")